package cn._tedu.egmvc1.controller;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * @author tune_the last
 * @date 2025/11/10 - 18:47
 */
@RestController
public class EmpController {
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    class Employee{
        private Integer id;
        private String name;
        private Integer sex;
        private Integer age;
        private Integer jobId;
    }
    @GetMapping("/emp/add")
    public String addEmp(String name, Integer sex, Integer age, Integer jobId){
        System.out.println("添加成功！" + "姓名=" + name + " 性别=" + sex + " 年龄=" + age + " 所属职位id=" + jobId);
        return "添加成功!";
    }
    @GetMapping("/emp/list")
    public String getAllEmp(){
        ArrayList<Employee> emps = new ArrayList<>();
        emps.add(new Employee(1, "蔡徐坤", 24, 2, 9));
        emps.add(new Employee(2, "乔碧萝", 59, 2, 5));
        emps.add(new Employee(8, "老八", 45, 1, 8));
        return emps.toString();
    }
    @GetMapping("/emp/update")
    public String updateEmp(Integer id, String name, Integer sex, Integer age, Integer jobId){
        System.out.println("修改成功！" + "员工id=" + id + "姓名=" + name + " 性别=" + sex + " 年龄=" + age + " 所属职位id=" + jobId);
        return "修改成功!";
    }

    @GetMapping("/emp/delete")
    public String deleteEmp(Integer id){
        System.out.println("删除了id为" + id + "的员工");
        return "删除了id为" + id + "的员工";
    }


}
